package com.example.a2302fx.adapter

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.a2302fx.R
import com.example.a2302fx.utils.GlideUtils
import com.example.base.entity.Order
import com.example.base.entity.OrderInfo

class OrderAdapter:BaseQuickAdapter<Order,BaseViewHolder>(R.layout.item_order) {
    override fun convert(holder: BaseViewHolder, item: Order) {
        holder.setText(R.id.tv_status,item.orderStatus)
        //rv
        val rv = holder.getView<RecyclerView>(R.id.order_rv)
        val childAdapter = ChildAdapter()
        childAdapter.data.addAll(item.orderInfoList)
        rv.adapter = childAdapter
        rv.layoutManager = LinearLayoutManager(context)
    }
}

class ChildAdapter:BaseQuickAdapter<OrderInfo,BaseViewHolder>(R.layout.item_order_child){
    override fun convert(holder: BaseViewHolder, item: OrderInfo) {
        holder.setText(R.id.child_name,item.storeName)
        holder.setText(R.id.child_num,"X${item.cartNum}")
        GlideUtils.loadNormal(context,item.image,holder.getView(R.id.child_iv))
    }

}